﻿namespace Digitalmes.Core.Common.PublishStrategies;

/// <summary>
/// 通知事件发布策略工厂
/// </summary>
public static class PublishStrategyFactory
{
    /// <summary>
    /// 创建通知事件发布策略对象。
    /// </summary>
    /// <param name="strategy">发布策略</param>
    /// <returns></returns>
    /// <exception cref="NotImplementedException"></exception>
    public static INotificationPublisher Create(PublishStrategy strategy)
    {
        return strategy switch
        {
            PublishStrategy.ParallelNoWait => new ParallelNoWaitPublisher(),
            PublishStrategy.AsyncContinueOnException => new AsyncContinueOnExceptionPublisher(),
            _ => throw new NotImplementedException(),
        };
    }
}
